﻿using CPPEI.BD.VMTool.Untils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CPPEI.BD.VMTool.Views
{
    /// <summary>
    /// SaveSolutionConfigWindow.xaml 的交互逻辑
    /// </summary>
    public partial class SaveSolutionConfigWindow : Window
    {
        private static int _numberCount;

        public  int saveSort;
        public  string SaveName;
        public  int SaveNumber;
        public SaveSolutionConfigWindow(int numberCount)
        {
            InitializeComponent();
            _numberCount = numberCount;
            this.Loaded += SaveSolutionConfigWindow_Loaded;
        }

        void SaveSolutionConfigWindow_Loaded(object sender, RoutedEventArgs e)
        {
            BindSorts();
            BindNumbers();
        }

        private void BindSorts()
        {
            _ctlComboBoxSorts.ItemsSource = VMSolutionUntil.GetSorts(true);
            _ctlComboBoxSorts.SelectedValuePath = "Id";
            _ctlComboBoxSorts.DisplayMemberPath = "Caption";
            _ctlComboBoxSorts.SelectedIndex = 0;
        }


        private void BindNumbers()
        {
            List<int> listNumber = new List<int>();
            listNumber.Add( _numberCount + 1);
            _ctlComboBoxNum.ItemsSource = listNumber;
            _ctlComboBoxNum.SelectedIndex = 0;
        }

        private void _ctlBtnSave_Click_1(object sender, RoutedEventArgs e)
        {

            _ctlBtnSave.Style = (Style)saveSolutionConfigWindow.Resources["selectSaveButton"];
            this.DialogResult = true;
            saveSort = Convert.ToInt32(this._ctlComboBoxSorts.SelectedValue.ToString());
            SaveName = _ctlTextBoxName.Text;
            SaveNumber = Convert.ToInt32(_ctlComboBoxNum.SelectedValue.ToString());
        }
    }
}
